﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using AimGameLibrary;
using AimGameEngine.EditorObject;

namespace AimGameEngine.NodeEditorObject
{
    public class NodeKeyController : NodeController
    {
        public Microsoft.Xna.Framework.Input.Keys mykeys;

        public NodeKeyController(SpriteBatch inputspritebatch, Camera inputcamera, NodeData inputData
            , List<IDraw> MyListDraw, List<IUpdateMainTime> MyListUpdateTime, Dictionary<String, NodeObject> MyListObject, Dictionary<String, NodeObject> MyListType)
            : base(inputspritebatch, inputcamera, inputData, MyListDraw,MyListUpdateTime, MyListObject, MyListType)
	    {
            InputMode = NodeInputMode.Pressed_Release;
            mykeys = Microsoft.Xna.Framework.Input.Keys.None;

	    }

        public override void ShowProprety(ArrayList Temp, CallBack input)
        {
            base.ShowProprety(Temp, input);
            PropretyKeyController propretykeycontroller = new PropretyKeyController(this);
            //propretykeycontroller.Deactivate += new EventHandler(input.Deactivate);
            propretykeycontroller.okButton.Click += new EventHandler(input.Deactivate);
            propretykeycontroller.ShowDialog();
            
        }

        public override void SaveData(System.Collections.ArrayList Thislist, SaveMode inputsavemode)
        {
            base.SaveData(Thislist,inputsavemode);

            Thislist.Add(mykeys);
            Thislist.Add(InputMode);

            SaveDataDictionary(Thislist);
        }

        public override void LoadData(Identification getdata, int IndexData)
        {
            base.LoadData(getdata, IndexData);

            if (getdata.Items.GetValue(IndexData + 1).GetType() == typeof(Microsoft.Xna.Framework.Input.Keys))
            mykeys = (Microsoft.Xna.Framework.Input.Keys)getdata.Items.GetValue(IndexData + 1);

            if (getdata.Items.GetValue(IndexData + 2).GetType() == typeof(NodeInputMode))
            InputMode = (NodeInputMode)getdata.Items.GetValue(IndexData + 2);

            SetupProprety();
        }
        //public override string CreateData(int IndexList)
        //{
        //    String TempPacketName = String.Empty;
        //    int Tempcount = 0;
        //    switch (IndexList)
        //    { 
        //        case 0:
        //            Tempcount = 0;
        //            foreach (String key0 in DictionaryObjectUpdateIsdown.Keys)
        //            {
        //                if (Tempcount > 0)
        //                    TempPacketName += "|";
        //                //TempPacketName += DictionaryObjectUpdateIsdown[key0].MyData.MyName;
        //                TempPacketName += key0;
        //                Tempcount++;
        //            }
        //            break;
        //        case 1:
        //            Tempcount = 0;
        //            foreach (String key1 in DictionaryObjectUpdateIsup.Keys)
        //            {
        //                if (Tempcount > 0)
        //                    TempPacketName += "|";
        //                //TempPacketName += DictionaryObjectUpdateIsup[key1].MyData.MyName;
        //                TempPacketName += key1;
        //                Tempcount++;
        //            }
        //            break;
        //        case 2:
        //            Tempcount = 0;
        //            foreach (String key2 in DictionaryObjectUpdatePressed.Keys)
        //            {
        //                if (Tempcount > 0)
        //                    TempPacketName += "|";
        //                //TempPacketName += DictionaryObjectUpdatePressed[key2].MyData.MyName;
        //                TempPacketName += key2;
        //                Tempcount++;
        //            }
        //            break;
        //        case 3:
        //            Tempcount = 0;
        //            foreach (String key3 in DictionaryObjectUpdateRelease.Keys)
        //            {
        //                if (Tempcount > 0)
        //                    TempPacketName += "|";
        //                //TempPacketName += DictionaryObjectUpdatePressed[key3].MyData.MyName;
        //                TempPacketName += key3;
        //                Tempcount++;
        //            }
        //            break;
        //    }
        //    return TempPacketName;
        //    //return base.CreateData(IndexList);
        //}
    }
}
